from tree_sitter import Language, Parser, Tree, Node
import tree_sitter_cpp

class TypeGet:
    def __init__(self):
        self.type_specifier = ["class_specifier",
                               "decltype",
                               "dependent_type",
                               "enum_specifier",
                               "placeholder_type_specifier",
                               "primitive_type",
                               "qualified_identifier",
                               "sized_type_specifier",
                               "struct_specifier",
                               "template_type",
                               "type_identifier",
                               "union_specifier"]
        
    """
    return subtype of type_specifier
    """
    def get_subtype_of_type_specifier(self) -> list:
        return self.type_specifier
    
    """
    type_specifier
    """
    def class_specifier(node: Node):
        return False
    
    def decltype(node: Node):
        return False
    
    def dependent_type(node: Node):
        return False
    
    def enum_specifier(node: Node):
        return False
    
    def placeholder_type_specifier(node: Node):
        return False
    
    def primitive_type(node: Node):
        return {"type": "primitive_type", "type_identifier": node.text.decode("utf-8")}
    
    def qualified_identifier(node: Node):
        return False
    
    def sized_type_specifier(node: Node):
        return {"type": "sized_type", "type_identifier": node.text.decode("utf-8")}
    
    def struct_specifier(node: Node):
        struct_name = None
        for child in node.children:
            if child.type == "type_identifier":
                struct_name = child.text.decode("utf-8")
        if struct_name is None:
            return False
        return {"type": "struct", "type_identifier": struct_name}
    
    def template_type(node: Node):
        return False
    
    def type_identifier(node: Node):
        return {"type": "unknown", "type_identifier": node.text.decode("utf-8")}
    
    def union_specifier(node: Node):
        return False